#include <map>
#include <vector>
#include <string>
#ifndef Lab_Chess
#define Lab_Chess
class Chess{
public:
    enum chess_type {
        King,
        Queen,
        Rook,
        Bishop,
        Knight,
        Pawn
    };
    Chess(int x_,int y_,int owner_):x(x_),y(y_),owner(owner_){};
    std::string chessword[6][2] = {{"w", "W"}, {"h", "H"}, {"c", "C"}, {"x", "X"}, {"m", "M"}, {"b", "B"}};
    void set_index(int x_,int y_);
    int get_x_index() const;
    int get_y_index() const;
    std::string get_sig();
    int get_owner();
    chess_type get_type();
    bool get_moved();
    virtual int check_move(const std::vector<Chess*> &chesses, int targetx, int targety)=0;//Return stu_code:0 for illegal movement, 1 for normal movement, and 2 for prey

protected : 
    int x; // the x index of the piece
    int y; // the y index of the piece
    bool moved; // rem the if chess has been moved
    chess_type type;// the type of the piece
    int alive; // if the piece still on board
    int owner;//the owner of the chess 0 or 1
};

class King : public Chess{
public:
    King(int x_, int y_, int owner_) : Chess(x_, y_, owner_)
    {
        moved = false;
        type = Chess::King;
    };

    int check_move(const std::vector<Chess *> &chesses, int targetx, int targety);
};
class Queen : public Chess{
public:
    Queen(int x_, int y_, int owner_) : Chess(x_, y_, owner_){
        moved = false;
        type = Chess::Queen;
    };

    int check_move(const std::vector<Chess *> &chesses, int targetx, int targety);
};
class Knight : public Chess{
public:
    Knight(int x_, int y_, int owner_) : Chess(x_, y_, owner_){
        moved = false;
        type = Chess::Knight;
    };

    int check_move(const std::vector<Chess *> &chesses, int targetx, int targety);
};
class Rook : public Chess{
public:
    Rook(int x_, int y_, int owner_) : Chess(x_, y_, owner_){
        moved = false;
        type = Chess::Rook;
    };

    int check_move(const std::vector<Chess *> &chesses, int targetx, int targety);
};
class Bishop : public Chess{
public:
    Bishop(int x_, int y_, int owner_) : Chess(x_, y_, owner_){
        moved = false;
        type = Chess::Bishop;
    };

    int check_move(const std::vector<Chess *> &chesses, int targetx, int targety);
};
class Pawn : public Chess{
public:
    Pawn(int x_, int y_, int owner_) : Chess(x_, y_, owner_){
        moved = false;
        type = Chess::Pawn;
    };

    int check_move(const std::vector<Chess *> &chesses, int targetx, int targety);
};
#endif